/**
 * Created by aa on 2016/9/22.
 */
'use strict';
var utils = require('../common/utils');
var cac = utils.cac;

//父标描述
const RECEIVE_PAR_MESSAGE = 'RECEIVE_PAR_MESSAGE';
//父标对应子产品
const RECEIVE_PAR_PRODUCT = 'RECEIVE_PAR_PRODUCT';

//对外暴露变量
exports.RECEIVE_PAR_MESSAGE = RECEIVE_PAR_MESSAGE;
exports.RECEIVE_PAR_PRODUCT = RECEIVE_PAR_PRODUCT;

var receiveParProduct;

//对外暴露方法
exports.receiveParMessage = cac(RECEIVE_PAR_MESSAGE, 'parMessage');
exports.receiveParProduct = receiveParProduct=cac(RECEIVE_PAR_PRODUCT, 'parProduct');


exports.getListByParId = (parId,pageSize,curPage)=> {
    if (parId === undefined) {
        return;
    }
    return (dispatch, getState) => {
        reqwest({
            url: '/api/getCurrentListByParIdForDetail?parId=' + parId+'&pageSize='+pageSize+'&curPage='+curPage,
            method: 'get',
            contentType: 'application/json'
        })
            .then(function (data) {
                dispatch(receiveParProduct(data));
            })
            .fail(function (err, msg) {
                alert('获取数据出错');
            })
    }
};